This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <condition_variable> | |
#include <mutex> | |
#include <queue> | |
#include <thread> | |
#include <memory> | |
#include <vector> | |
#include "unistd.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# | |
# smartmontools-run.d-notify - Smartmontools visual notification script for desktop environments | |
# | |
# https://gist.github.com/aplatanado/1331876d6e1547aeb9b2d02861e9ae92 | |
# | |
# Requires notify-send-all: | |
# https://gist.github.com/aplatanado/e8810dbceece820b4ae5aa0ee5ca200 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/cron.d/snapraid: crontab entries for snapraid package | |
# Run a SnapRAID diff and then sync | |
30 23 * * * root /usr/local/sbin/snapraid_diff_n_sync.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# notify-send-all - Script to send desktop notifications to all active sessions | |
# | |
# https://gist.github.com/aplatanado/e8810dbceece820b4ae5aa0ee5ca200a | |
# | |
### Utility functions | |
# A few utility functions to show errors, handle programa exit and more |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyThread : public QThread | |
{ | |
Q_OBJECT | |
protected: | |
void run(); | |
}; | |
void MyThread::run() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FiniteBuffer : public QObject | |
{ | |
Q_OBJECT | |
public: | |
FiniteBuffer(int size); | |
~FiniteBuffer(); | |
// Métodos de inserción y extracción para el productor y el | |
// consumidor, respectivamente. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void MyWindow::on_video_updated(const QRect& rect) | |
{ | |
finiteBuffer_->insertFrame(movie_->currentImage()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void FiniteBuffer::insertFrame(const QImage& frame) | |
{ | |
// Bloquear el cerrojo. Es lo mismo que hacer manualmente: | |
// mutex_.lock() | |
QMutexLocker lock(&mutex); | |
// El código del productor a partir de este punto no se | |
// ejecutará si el consumidor ha bloqueado el cerrojo | |
// primero. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FrameProcessingThread : public QThread | |
{ | |
Q_OBJECT | |
public: | |
FrameProcessingThread(FiniteBuffer* buffer, | |
QObject *parent = 0) | |
: QThread(parent), buffer_(buffer) | |
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QImage FiniteBuffer::extractFrame() | |
{ | |
// Bloquear el cerrojo. Es lo mismo que hacer manualmente: | |
// mutex_.lock() | |
QMutexLocker lock(&mutex); | |
// El código del productor a partir de este punto no se | |
// ejecutará si el productor ha bloqueado el cerrojo | |
// primero. | |
OlderNewer